﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using SYH.Config;
using Common;

namespace SYH.User.DAL
{
   public  class UserInfoDetail
    {
        #region 得到会员详细信息
        /// <summary>
        /// 得到会员详细信息
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="Type"></param>
        /// <returns></returns>
        public string GetContent(int UserId, int Type)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@UserId", SqlDbType.Int,4),
                    new SqlParameter("@Type", SqlDbType.Int,4)
			};
            parameters[0].Value = UserId;
            parameters[1].Value = Type;
            SqlDataReader sdr = Common.SqlHelper.ExecuteReader(WebConfig.SqlConnString, CommandType.StoredProcedure, "User_InfoDetail_GetContent", parameters);
            if (sdr.HasRows)
            {
                sdr.Read();
                string content = sdr.GetString(sdr.GetOrdinal("Content")).ToString();
                sdr.Close();
                return content;
            }
            sdr.Close();
            return "";
        }
        #endregion

        #region 增
        /// <summary>
        /// 增加一条数据,根据UserId和Type判断如果存在则执行更新
        /// </summary>
        public int Add(SYH.User.Model.UserInfoDetail model)
        {
            string noHtmlContent = Common.StringHelper.RemoveHtml(model.Content);
            return TypeParse.ObjectToInt(SqlHelper.ExecuteScalar(WebConfig.SqlConnString,
                CommandType.StoredProcedure,
                "User_InfoDetail_Add",
                new SqlParameter("@UserId", model.UserId),
                new SqlParameter("@Type", model.Type),
                new SqlParameter("@Content", model.Content)
               ), 0);  //, new SqlParameter("@Summary", noHtmlContent)
        }
        #endregion

    }
}
